home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
turbovis
/
tvtool17.zip
/
TVTOOLS.ZIP
/
INDATE.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-05-13
|
1KB
|
66 lines
/* Copyright (C) 1993 Marc Stern (internet: stern@mble.philips.be) */
#define Uses_TStreamable
#define Uses_MsgBox
#define Uses_TInputDate
#include "tvtools.h"
__link( RInputLine )
#include <string.h>
#include <stdio.h>
#include <values.h>
#include <stdlib.h>
#include <strstream.h>
#include "date.h"
// TInputDate
const char * const TInputDate::name = "TInputDate";
TInputDate::TInputDate( const TRect& bounds )
:TInputRegExp( bounds, 7, "0-9" )
{
}
TInputDate::TInputDate( int x, int y )
:TInputRegExp( x, y, 7, "0-9" )
{
}
Boolean TInputDate::valid( ushort command )
{
switch( command )
{
case cmReleasedFocus: break;
case cmQuit :
case cmClose:
case cmOK :
if ( ! *data ) break; // Allow empty entry
unsigned long yymmdd = 0;
sscanf( data , "%lu" , &yymmdd );
#pragma warn -sig
int year = yymmdd / 10000;
int month = (yymmdd % 10000) / 100;
int day = yymmdd % 100;
#pragma warn .sig
if ( ! isdatevalid(day, month, year) )
{
select();
messageBox( " \n\03Invalid date !", mfError | mfOKButton );
selectAll( True );
return False;
}
break;
}
return TInputRegExp::valid( command );
}